package org.utils;

import org.opencv.core.Mat;
import org.opencv.highgui.HighGui;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;

public class ImageUtil {

    public static void saveImage(Mat img, String fileName) {
        try {
            Image image = HighGui.toBufferedImage(img);
            BufferedImage bi = (BufferedImage) image;
            ImageIO.write(bi, "png", new File(fileName));
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
